package com.zhu.ttwords.view.activity;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.KeyEvent;

import com.zhu.ttwords.R;

public class StudyActivity extends ActionBarActivity  {

    Dialog exitDialog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_study);
        exitDialog = new AlertDialog.Builder(this).setTitle("退出本次学习")
                .setMessage("完成学习了吗？")
                .setPositiveButton("退出", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        StudyActivity.this.finish();
                    }
                }).setNegativeButton("继续学习", null).create();

    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
                exitDialog.show();
                break;
        }
        return true;
    }

}
